#include <signal.h>
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <assert.h>
#include <cassert>

#include <sys/wait.h>

using namespace std;

int g_val = 0;
void handler(int sig)
{
    cout << "signal doing!" << endl;
    cout << "g_val:" << g_val << endl;
    g_val = 1;
}
int main()
{
    signal(3, handler);

    while (!g_val)
    {
        cout << "hhhh" << endl;
        sleep(1);
    }

    cout << "main ending!" << endl;
    return 0;
}